import 'dart:io';
import 'dart:async';
import 'dart:convert';

class RequestUtils {
  static Future getData(String url) async {
    var result;
    var httpClient = new HttpClient();
    try {
      var request = await httpClient.getUrl(Uri.parse(url));
      var response = await request.close();
      if(response.statusCode==HttpStatus.OK) {
        var resp = await response.transform(utf8.decoder).join();
        result = json.decode(resp);
      } else {
        result = "Error getting json data: Http Status ${response.statusCode}";
      }
    } catch (e) {
      result = "Error getting json data: Exception Message ${e.toString()}";
    }
    return result;
  }
}